<?php

if (class_exists('testDataPath'))
	return;

class testDataPath extends UnitTestCase {
	
	function setUp() {
		$this->data=array(
		'A' => 'Aaaaah !'
		,'B' => array('be&ecirc;h','baie')
		,'C'=>array(
			'un'=>1
			,'deux'=>2
			,'trois'=>3)
		,'D'=>array());
	}

	function testGet() {
		$this->assertEqual(datapath::get($this->data,'A'), 'Aaaaah !');
		$this->assertEqual(datapath::get($this->data,'B.1'), 'baie');
		$this->assertEqual(datapath::get($this->data,'C.trois'), 3);
		// proprietes d'objet
		$this->assertEqual(datapath::get($this,'data.C.un'), 1, "could not get object member");
		// valeur inexistante
		$this->assertNull(datapath::get($this->data['D.0']), "can grab null value ?");
		
		$this->assertEqual(datapath::get($this->data['D']), array(), "can't grab empty array ?");
	}
	
	function testSet() {
		datapath::set($this->data,'Dede','D.d');
		$this->assertEqual($this->data['D']['d'], 'Dede', 'could not set a value');
		datapath::set($this,42,'solution');
		$this->assertEqual($this->solution, 42, 'could not set a member');
		datapath::set($this,42,'data.solution');
		$this->assertEqual($this->data['solution'], 42, 'could not set a value in a member');
		// print_r($this->data);
	}
}
?>